package com.sdx.console.contract.service;

import java.util.List;

import com.ibeetl.admin.core.entity.BaseEntity;
import com.sdx.console.contract.dao.ContractMemberDao;
import com.sdx.console.contract.entity.ContractMember;
import com.sdx.console.customer.entity.CustomerInfo;
import org.beetl.sql.core.engine.PageQuery;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ibeetl.admin.core.util.PlatformException;

import com.sdx.console.contract.dao.ContractInfoDao;
import com.sdx.console.contract.entity.ContractInfo;
import com.ibeetl.admin.core.service.BaseService;

/**
 * ContractInfo Service
 */

@Service
@Transactional
public class ContractInfoService extends BaseService<ContractInfo>{

    @Resource
	private ContractInfoDao contractInfoDao;

    @Resource
    private ContractMemberDao contractMemberDao;

    public PageQuery<ContractInfo>queryByCondition(PageQuery query){
        PageQuery ret =  contractInfoDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelContractInfo(List<String> ids){
        try {
            contractInfoDao.batchDelContractInfoByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除ContractInfo失败", e);
        }
    }

    public void fkStatusContractInfoByIds(Integer fkStatus, List<String> ids) {
        contractInfoDao.fkStatusContractInfoByIds(fkStatus, ids);
    }
	public List<ContractInfo> all() {
		return contractInfoDao.all();
		}

    public List<String> selectContractMemberById(Integer contractId){
        return  contractInfoDao.selectContractMemberById(contractId);
    }

    public void delBatchContractMember(Integer contractId){
        contractInfoDao.delBatchContractMember(contractId);
    }

    public void insertContractMember(List<ContractMember> list){
        contractMemberDao.insertBatch(list);
    }

    public List<CustomerInfo> selectCustomerInfo(String customerIds){
        return contractInfoDao.selectCustomerInfo(customerIds);
    }
}